/*
 * Wazuh Vulnerability Scanner - Unit Tests
 * Copyright (C) 2015, Wazuh Inc.
 * December 13, 2023.
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 2) as published by the FSF - Free Software
 * Foundation.
 */

#ifndef _OS_DATA_CACHE_TEST_HPP
#define _OS_DATA_CACHE_TEST_HPP

#include "osDataCache.hpp"
#include "policyManager.hpp"
#include "socketServer.hpp"
#include "wdbDataException.hpp"
#include "gtest/gtest.h"
#include <filesystem>

/**
 * @brief Runs unit tests for osDataCache
 */
class OsDataCacheTest : public ::testing::Test
{
protected:
    // LCOV_EXCL_START
    OsDataCacheTest() = default;
    ~OsDataCacheTest() override = default;
    // LCOV_EXCL_STOP

    /**
     * @brief Set the Up every test case.
     *
     */
    void SetUp() override
    {
        std::filesystem::create_directories("queue/db");

        // Policy manager initialization.
        const auto& configJson {nlohmann::json::parse(R"({
        "vulnerability-detection": {
            "enabled": "yes",
            "index-status": "yes",
            "cti-url": "cti-url.com"
        },
        "osdataLRUSize":1000,
        "clusterName":"cluster01",
        "clusterEnabled":false
        })")};
        PolicyManager::instance().initialize(configJson);
    }

    /**
     * @brief Clean up method after every test execution.
     *
     */
    void TearDown() override
    {
        PolicyManager::instance().teardown();
        std::filesystem::remove_all("queue/db");
    }
};

#endif // _OS_DATA_CACHE_TEST_HPP
